-- 技能名
local wenmingjiaoshi_other = fk.CreateSkill {
    name = "mcdh_wenmingjiaoshi_other",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

wenmingjiaoshi_other:addEffect('active',{
    card_num = 0,
    target_num = 1,
    can_use = function(self, player)
        return not player:isKongcheng() and #table.filter(Fk:currentRoom().alive_players,function(p) return p:hasSkill("mcdh_wenmingjiaoshi") and p:getMark("@@wenmingjiaoshi-turn") ==  0 and p ~= player end) ~= 0
    end,
    card_filter = Util.FalseFunc,
    target_filter = function(self,player, to_select, selected)
        return #selected == 0 and to_select ~= player and player:canPindian(to_select)
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local target =effect.tos[1]
        local haveSkillPlayers =table.filter(Fk:currentRoom().alive_players,function(p) return p:hasSkill("mcdh_wenmingjiaoshi") and p:getMark("@@wenmingjiaoshi-turn") ==  0 and p ~= player end)
        --场上有多个角色拥有的话选择发动谁的
        if #haveSkillPlayers == 1  then
            room:setPlayerMark(haveSkillPlayers[1],"@@wenmingjiaoshi-turn",1)
        else
            local to = room:askToChoosePlayers(player, {
                targets = haveSkillPlayers,
                min_num = 1,
                max_num = 1,
                prompt = "#wenmingjiaoshi-skill",
                skill_name = self.name,
                cancelable = false
              })[1]
            room:setPlayerMark(to,"@@wenmingjiaoshi-turn",1)
        end
        local pindian = player:pindian({target}, self.name)
        if pindian.results[target.id].winner == player then
            --无次数限制？
            U.askForUseVirtualCard(room, player, "slash", nil, self.name, "#wenmingjiaoshi-use", false, false, false, false)
        else
            target:drawCards(1,self.name)
        end
    end,
})

Fk:loadTranslationTable {
    ["wenmingjiaoshi&"] = "文明矫饰",
    [":wenmingjiaoshi&"] = "出牌阶段限一次，你可以令文的〖文明矫饰〗失效并与一名角色拼点，若你赢，你视为使用一张【杀】；没赢，则对方摸一张牌。",
    ["#wenmingjiaoshi"] = "文明矫饰：令文的〖文明矫饰〗失效并与一名角色拼点，若你赢，你视为使用一张【杀】；没赢，则对方摸一张牌。",
    ["#wenmingjiaoshi-use"] = "文明矫饰：视为使用一张【杀】",
    ["#wenmingjiaoshi-skill"] = "文明矫饰：选择一个拥有此技能的目标",
}

return wenmingjiaoshi_other